# 用requests框架 主要针对 模拟登录,记住Session,携带cookie访问请求
import requests

headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36",
    "referer": "",
}

# 创建会话
session = requests.session()

# 1. 登录
url = "https://passport.17k.com/ck/user/login"
data = {
    "loginName": "18649325921",
    "password": "Abc123.",
}
resp = session.post(url, data=data, headers=headers)
resp.encoding = 'utf-8'
print(resp.content)

# 2. 携带cookie访问
url = "https://user.17k.com/www/"
print(resp.cookies)
resp = session.get(url, headers=headers)
resp.encoding = 'utf-8'
print(resp.text)

# 记得关闭
resp.close()